package cn.guxinhu.billsystem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class LoginConfig implements WebMvcConfigurer {

    public LoginConfig(BillInterceptor billInterceptor) {
        this.billInterceptor = billInterceptor;
        System.out.println("LoginConfig");
    }

    @Autowired
    BillInterceptor billInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(billInterceptor);
        registration.addPathPatterns("/**");                      //所有路径都被拦截
        registration.excludePathPatterns(                         //添加不拦截路径
                "/user/main",            //登录
                "/user/login",            //登录
                "/static/**",
                "/easyui/**",
                "/kaptcha/**",
                "/*/*.css",
                "/*/*.js",
                "/*/*.jpeg"
        );
    }
}
